﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Index2.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<App.Views.ViewModels.UCServicesItemListViewModel>>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
冷藏服务
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="HeadContent" runat="server">
    <script type="text/javascript">
        var id = 'RefriNO';
        var ctrlName = 'RefriService';
        var itemListId = '#uc_service_item_list';
        function Crud2(id, ctrlName) {
            Crud.call(this,id,ctrlName);
            this.Create = function () {
                this.url = '../' + ctrlName + '/Create';
                url = this.url;
                $('#dlg').dialog({
                    onBeforeOpen: function () {
                        $(itemListId).load(url);
                    }
                });
                $('#dlg').dialog('open').dialog('setTitle', '新增');
                $('#fm').form('clear');
                var curTime = new Date().Format('yyyy-MM-dd hh:mm:ss');
                $('#fm').form('load', { 'EnterTime': curTime, 'EstimateOutTime': curTime });
            };
            this.Edit = function () {
                var row = $('#dg').datagrid('getSelected');
                if (row) {
                    this.url = '../' + ctrlName + '/Edit?id=' + row[id] + "&s=" + (new Date()).getTime();
                    url = this.url;
                    $('#dlg').dialog({ onBeforeOpen: function () {
                        $(itemListId).load(url);
                    } });
                    $('#dlg').dialog('open').dialog('setTitle', '修改');
                    row['EnterTime'] = JsonToDateString(row['EnterTime'], 'yyyy-MM-dd hh:mm:ss');
                    row['EstimateOutTime'] = JsonToDateString(row['EstimateOutTime'], 'yyyy-MM-dd hh:mm:ss');
                    row['ActualOutTime'] = JsonToDateString(row['ActualOutTime'], 'yyyy-MM-dd hh:mm:ss');
                    $('#fm').form('load', row);
                } else {
                    $.messager.alert("提示", "请选择一条记录进行编辑!");
                }
            };
        }
        
        var crud = new Crud2(id, ctrlName);

        $(function () {            

            //选择冷藏棺
            $('#CoffinNO').click(function () {
                $.ajaxSetup({ cache: false });
                var url = '../' + ctrlName + '/SelectCoffin?st=' + $('#StartTime').val() + '&et=' + $('#EndTime').val();
                url = encodeURI(url);
                $('#dlgSelectHalls').dialog({
                    modal: true,
                    width: 450,
                    height: 300,
                    inline: true,
                    title: '选择守灵厅',
                    onBeforeOpen: function () {
                        $('#hallList').load(url);
                    },
                    toolbar: [{
                        id: 'btnOk',
                        text: '确定',
                        iconCls: 'icon-ok',
                        handler: function () {
                            var items = $(':radio:checked');                            
                            if (items.length > 0) {
                                $('#CoffinNO').val(items[0].value);
                            }
                            $('#dlgSelectHalls').dialog('close');
                        }
                    }]
                });
                $('#dlgSelectHalls').dialog('open');                
            });
            $('#dg').datagrid({
                title: '冷藏服务',
                iconCls: 'icon-save',
                url: '../' + ctrlName + '/List',
                sortName: id,
                sortOrder: 'asc',
                remoteSort: false,
                idField: id,
                frozenColumns: [[
	                { field: 'ck', checkbox: true },
	                { title: '编号', field: id, width: 100, sortable: true }
				]],
                columns: [[
                        { field: 'ServiceNo', title: '冷藏编号', width: 80 },
                        { field: 'CoffinNO', title: '冷藏棺', width: 80 },
                        { field: 'EnterTime', title: '入棺时间', width: 80,
                            formatter: function (value) {
                                return JsonToDateString(value, 'yyyy-MM-dd hh:mm:ss');
                            }
                        },
                        { field: 'EstimateOutTime', title: '预计出棺时间', width: 80,
                            formatter: function (value) {
                                return JsonToDateString(value, 'yyyy-MM-dd hh:mm:ss');
                            }
                        },
                        { field: 'ActualOutTime', title: '实际出棺时间', width: 80,
                            formatter: function (value) {
                                return JsonToDateString(value, 'yyyy-MM-dd hh:mm:ss');
                            }
                        }
                    ]],
                pagination: true,
                fitColumns: true,
                toolbar: toolbar
            });
        });      
    </script>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <div id="dlg" class="easyui-dialog" closed="true" buttons="#dlg-buttons" 
			style="width:580px;height:450px;padding:5px 5px">
		<div class="ftitle">冷藏服务信息</div>
		<form id="fm" method="post">            
			<table width="100%">
                <tr>
                    <td width="80" align="right">编号</td>
                    <td><input id="RefriNO" name="RefriNO" class="easyui-validatebox" />
                        <input id="ServiceNo" name="ServiceNo" type="hidden" />
                    </td>
                    <td  width="80" align="right">死者编号</td>
                    <td><input id="DeadNO" name="DeadNO" class="easyui-validatebox" required="true" /></td>
                </tr>
                <tr>
                    <td align="right">入棺时间</td>
                    <td><input class="easyui-datetimebox" id="EnterTime" name="EnterTime" required="true" style="width:150px"/>                        
                    </td>
                    <td align="right">预计出棺时间</td>
                    <td><input class="easyui-datetimebox" id="EstimateOutTime" name="EstimateOutTime" required="true" style="width:150px"/></td>
                </tr>                
                <tr>
                    <td align="right">选择冷藏棺</td>
                    <td ><input name="CoffinNO" id="CoffinNO" class="easyui-validatebox" /></td>  
                    <td align="right">冷藏时长(小时)</td>
                    <td ><input id="ServiceFees" name="ServiceFees" class="easyui-numberbox" precision="0" /></td>                   
                </tr>
                <tr>
                    <td colspan="4">
                        <%Html.RenderPartial("UCServicesItemList", Model);%>                                          
                    </td>
                </tr>
            </table>             
		</form>        
        <!-- 用来显示冷藏棺选择界面 -->
        <div id="dlgSelectHalls">
            <div id="hallList"></div>
        </div> 
        <!-- 选择死者列表 -->
        <% Html.RenderPartial("UCSelectDeadNo"); %>
	</div>
</asp:Content>


